package cn.itcast.bos.dao.base;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import cn.itcast.bos.domain.base.Standard;

public interface StandardRepository extends JpaRepository<Standard, Integer>{

	public List<Standard> findByName(String name);
	
	public List<Standard> findByMinWeight(Integer min);
	
	public List<Standard> findByNameAndMaxWeight(String name,Integer max);
	
	/**
	 * 以下是自定义的
	 */
	@Query(value="from Standard where maxWeight>?")
	public List<Standard> gtByMax(Integer value);
	
	@Query(value="from Standard where minWeight between ?2 and ?1")
	public List<Standard> bwAB(Integer a,Integer b);
	
	@Query(value="select * from T_STANDARD",nativeQuery=true)
	public List<Standard> myAll();
	
	/**
	 * 删改操作
	 */
	@Query(value="update Standard set maxLength=?2 where id=?1")
	@Modifying
	public void updateMaxLength(Integer id,Integer maxLength);
	
}
